<?php use_helper('I18N') ?>
<script type="text/javascript">
function formchecking(){	
	var txtusername = document.getElementById('username').value;
	var txtemail = document.getElementById('email').value;
	
	if (txtusername.length <= 0) {
		alert('Please enter your username');
		return false;
	} else {
		if (txtemail.length <= 0) {
			alert('Please enter your email');
			return false;
		}
	}
	
	document.getElementById('frmlogin').submit();
}

function emailchecking()
{
	var s = document.getElementById('email').value;
	var result = false;
	var idx1 = 0;
	var idx2 = 0;
	
	if(s != ''){
		for (var i=0; i<s.length; i++)
		{	
			if ('@' == s.charAt(i)) {
				result = true;
				idx1 = i;
			}
			
			if('.' == s.charAt(i)) {
				idx2 = i;
			}
		}
		
		if (result == false || idx1 > idx2) {
			document.getElementById('email').value="";
			document.getElementById('email').focus();
			alert("Invalid email address");
		}
	}
}
</script>

<?php echo form_tag('user/forgetpass', array('id' => 'frmlogin', 'name' => 'frmlogin')) ?>

<table class="main">
	<tr>
    	<td valign="top"><img src="/images/welcome.jpg" /></td>
        <td><img src="/images/divider.jpg" /></td>
        <td valign="top" align="center"><img src="/images/logo.jpg" />
        	<br /><br />
        	<?php
			if($success_message=="success"){
			?>	
            <span class="title">THANK YOU</span>
            <br />
            The new password had sent to your email address
            <br /><br />
            Please <a href="/user/login">here</a> to login
            <?php
			}else{
			?>
            <span class="title">PLEASE ENTER YOUR DETAILS</span>
            <br />
            <table width="236">            
                <tr>
                	<td colspan="2" align="left">Please key in your Username and <br />Email to reset your password</td>
                </tr>
            	<tr>
                	<td align="left" colspan="2">User Name:</td>
                </tr>
                <tr>
                	<td colspan="2" align="left"><?php echo input_tag('username') ?></td>
                </tr>
                <tr>
                	<td align="left" colspan="2">Email:</td>
                </tr>
                <tr>
                	<td colspan="2" align="left"><?php echo input_tag('email', '', array('onChange' => 'emailchecking()')) ?></td>
                </tr>               
                <tr>
                	<td align="left"><img name="btnLogin" id="btnLogin" onmouseover="roll_over('btnLogin', '/images/reset_btnAF.jpg')" onmouseout="roll_over('btnLogin', '/images/reset_btn.jpg')" src="/images/reset_btn.jpg" onClick="return formchecking();"/></td>
                	<td align="left"><img name="btnCancel" id="btnCancel" onmouseover="roll_over('btnCancel', '/images/back_btnAF.jpg')" onmouseout="roll_over('btnCancel', '/images/back_btn.jpg')" src="/images/back_btn.jpg" onClick="location.href='/user/login'"/></td>
                </tr>
                <tr>
                	<td colspan="2" class="error" align="left">
                	<?php
						if(!empty($error_message)){
							echo $error_message;
							$error_message='';
						}
					?>
					</td>
                </tr>
            </table>
            <?php
			}
			?>    
        </td>
    </tr>
</table>

</form>
